package com.lovo.common.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableRabbit
public class FanoutMQConfig {
    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("shop.fanout.exchange",true,false);
    }
    @Bean
    public Queue fanoutQueueA(){
        return new Queue("shop.fanout.queue.a",true);
    }
    @Bean
    public Queue fanoutQueueB(){
        return new Queue("shop.fanout.queue.b",true);
    }
    @Bean
    public Binding fanoutExchangeQueueABinding(){
        return BindingBuilder.bind(fanoutQueueA()).to(fanoutExchange());
    }
    @Bean
    public Binding fanoutExchangeQueueBBinding(){
        return BindingBuilder.bind(fanoutQueueB()).to(fanoutExchange());
    }
}
